package iscript.gameFramework.GameLite.content
{
	import flash.display.BitmapData;
	import flash.utils.Dictionary;
	import iscript.gameFramework.GameLite.events.GameContentEvent;
	
	internal class BitmapDataGroupContent implements IGameContent
	{
		
		private var _data:Dictionary = new Dictionary();
		private var _gameContent:GameContent
		
		public function BitmapDataGroupContent(gameContent:GameContent)
		{
			_gameContent = gameContent;
		}
		
		public function add(key:*, bitmapdatas:Vector.<BitmapData>):void
		{
			//if (_data.containKey(key))//throw new Error("BitmapDataContent has the key");
			if (_data[key] == null)
			{
				_data[key] = bitmapdatas;
				var event:GameContentEvent = new GameContentEvent(GameContentEvent.ADDBITMAPDATA);
				event.key = key;
				event.content = bitmapdatas;
				_gameContent.dispatchEvent(event);
				
				var e:GameContentEvent = new GameContentEvent(GameContentEvent.EVERYTHING)
				e.key = key;
				e.content = bitmapdatas;
				_gameContent.dispatchEvent(e);
			}
		
		}
		
		public function get(key:*):Vector.<BitmapData>
		{
			return _data[key];
		}
		
		public function contain(key:*):Boolean
		{
			return _data[key] != null;
		}
		
		public function remove(key:*):void
		{
			delete _data[key];
		}
	
	/*	public function clear():void {
	      _data.clear();
	     }
	 */
	}

}